package dongshi.daddy.adaptive;

import com.alibaba.dubbo.common.URL;
import com.alibaba.dubbo.common.extension.ExtensionLoader;
import org.junit.Test;

public class ExtensionLoaderTest {

  @Test
  public void testGetExtensionLoader() {
    // 首先创建一个模拟用的URL对象
//    URL url = URL.valueOf("dubbo://192.168.0.101:20880?fruit.granter=banana");
    URL url = URL.valueOf("dubbo://192.168.0.101:20880?find.fruit.extenstion=banana");
//    URL url = URL.valueOf("dubbo://192.168.0.101:20880");
    // 通过ExtensionLoader获取一个FruitGranter对象
    ExtensionLoader<FruitGranter> extensionLoader = ExtensionLoader.getExtensionLoader(FruitGranter.class);
    FruitGranter granter = extensionLoader.getAdaptiveExtension();
    // 使用该FruitGranter调用其"自适应标注的"方法，获取调用结果
    String result = granter.watering(url);
    System.out.println(result);
  }
}
